#include<iostream>
#include<string>
using namespace std;

//流

//标准输入输出流
/*class stu{
	string name;
	int age;
public:
	stu(){
		name = "";
		age = 0;
	}
	friend istream & operator>>(istream &in, stu &s);
	friend ostream & operator<<(ostream &out, stu &t);
};

istream & operator>>(istream &in, stu &t){
	in>>t.name>>t.age;
	return in;
}

ostream & operator<<(ostream &out, stu &t){
	out<<t.name<<"  "<<t.age<<endl;
	return out;
}

int main()
{
	stu s1, s2;
	cin >> s1 >> s2;
	cout << s1 << s2;
	return 0;
}*/

//文件流
//文本文件
/*class stu{
public:
	string name;
	int age;
	double score;
public:
	stu(string n, int a, double s){
		name = n;
		age = a;
		score = s;
	}
};

int main(){
	stu s[3] = {stu("张三", 21, 89.6), stu("李四", 24, 86.9), stu("王五", 20, 78.4)};

    //输出流-保存数据
	ofstream out("D:\\stuinfo.txt");
	for(int i = 0; i < 3; i++)
		out << s[i].name << "  " << s[i].age << "  " << s[i].score << endl;
	out.close();
	
    //输入流-读数据
	ifstream in("D:\\stuinfo.txt");
	stu temp;
	for(int i = 0; i < 3; i++){
		in>>temp.name>>temp.age>>temp.score;
	    cout << temp.name << "  " << temp.age << "  " << temp.score << endl;
	}
	in.close();
		
	return 0;
}*/

//二进制文件
/*struct stu{
	char name[10];
	int age;
	double score;
};

int main(){
	stu s[3] = {"张三", 21, 89.6, "李四", 24, 86.9, "王五", 20, 78.4};
	//输出流-保存数据
	ofstream out("D:\\stu.txt", ios::binary);
	out.write((char *)s, sizeof(s));
	out.close();
	
	//输入流-读数据
	ifstream in("D:\\stu.txt", ios::binary);
	stu t[3];
	in.read((char *)t, sizeof(t));
	for(int i = 3; i < 3; i++)
		cout << t[i].name << "  " << t[i].age << "  " << t[i].score << endl;
	in.close();
	return 0;
}*/
